/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.lzyzsd.circleprogress.utils.properties.model;

import com.github.lzyzsd.circleprogress.Utils;
import com.github.lzyzsd.circleprogress.utils.properties.ArcProgressResPropertyHolder;
import com.github.lzyzsd.circleprogress.utils.properties.IInterface.CommonPropertyModel;
import ohos.agp.components.AttrSet;
import ohos.agp.utils.Color;
import ohos.app.Context;

public class ArcProgressModel extends CommonPropertyModel {
    private Color finishedStrokeColor = new Color(Color.rgb(255,255,255));
    private Color unfinishedStrokeColor = new Color(Color.rgb(66,145,241));
    private Color textColor = new Color(Color.rgb(66,145,241));
    private int textSize = 30;
    private float arcAngle = 360 * 0.8f;
    private int strokeWidth = 8;
    private int suffixTextSize = 30;
    private String suffixText = "%";
    private int suffixTextPadding = 2;
    private int bottomTextSize = 16;
    private String bottomText = "";
    private int progress = 0;
    private int max = 100;

    public ArcProgressModel(Context context) {
        textSize = Utils.sp2px(context.getResourceManager(),40);
        suffixTextSize = Utils.sp2px(context.getResourceManager(),15);
        suffixTextPadding = Utils.dp2px(context.getResourceManager(),4);
        bottomTextSize = Utils.dp2px(context.getResourceManager(), 10);
        strokeWidth = Utils.dp2px(context.getResourceManager(), 4);
    }

    public Color getFinishedStrokeColor() {
        return finishedStrokeColor;
    }

    public Color getUnfinishedStrokeColor() {
        return unfinishedStrokeColor;
    }

    public Color getTextColor() {
        return textColor;
    }

    public int getTextSize() {
        return textSize;
    }

    public float getArcAngle() {
        return arcAngle;
    }

    public int getStrokeWidth() {
        return strokeWidth;
    }

    public int getSuffixTextSize() {
        return suffixTextSize;
    }

    public String getSuffixText() {
        return suffixText;
    }

    public int getSuffixTextPadding() {
        return suffixTextPadding;
    }

    public int getBottomTextSize() {
        return bottomTextSize;
    }

    public String getBottomText() {
        return bottomText;
    }

    public int getProgress() {
        return progress;
    }

    public int getMax() {
        return max;
    }

    public void setFinishedStrokeColor(Color finishedStrokeColor) {
        this.finishedStrokeColor = finishedStrokeColor;
    }

    public void setUnfinishedStrokeColor(Color unfinishedStrokeColor) {
        this.unfinishedStrokeColor = unfinishedStrokeColor;
    }

    public void setTextColor(Color textColor) {
        this.textColor = textColor;
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
    }

    public void setArcAngle(float arcAngle) {
        this.arcAngle = arcAngle;
    }

    public void setStrokeWidth(int strokeWidth) {
        this.strokeWidth = strokeWidth;
    }

    public void setSuffixTextSize(int suffixTextSize) {
        this.suffixTextSize = suffixTextSize;
    }

    public void setSuffixText(String suffixText) {
        this.suffixText = suffixText;
    }

    public void setSuffixTextPadding(int suffixTextPadding) {
        this.suffixTextPadding = suffixTextPadding;
    }

    public void setBottomTextSize(int bottomTextSize) {
        this.bottomTextSize = bottomTextSize;
    }

    public void setBottomText(String bottomText) {
        this.bottomText = bottomText;
    }

    public void setProgress(int progress) {
        this.progress = progress;
    }

    public void setMax(int max) {
        this.max = max;
    }

    public static class Builder {
        private ArcProgressModel arcProgressModel;

        public Builder(Context context, AttrSet set) {
            arcProgressModel = new ArcProgressResPropertyHolder(context,set).obtainProperty(); //init with default value
        }

        public Builder setFinishedStrokeColor(Color finishedStrokeColor) {
            arcProgressModel.finishedStrokeColor = finishedStrokeColor;
            return this;
        }

        public Builder setUnfinishedStrokeColor(Color unfinishedStrokeColor) {
            arcProgressModel.unfinishedStrokeColor = unfinishedStrokeColor;
            return this;
        }

        public Builder setTextColor(Color textColor) {
            arcProgressModel.textColor = textColor;
            return this;
        }

        public Builder setTextSize(int textSize) {
            arcProgressModel.textSize = textSize;
            return this;
        }

        public Builder setArcAngle(float arcAngle) {
            arcProgressModel.arcAngle = arcAngle;
            return this;
        }

        public Builder setStrokeWidth(int strokeWidth) {
            arcProgressModel.strokeWidth = strokeWidth;
            return this;
        }

        public Builder setSuffixTextSize(int suffixTextSize) {
            arcProgressModel.suffixTextSize = suffixTextSize;
            return this;
        }

        public Builder setSuffixText(String suffixText) {
            arcProgressModel.suffixText = suffixText;
            return this;
        }

        public Builder setSuffixTextPadding(int suffixTextPadding) {
            arcProgressModel.suffixTextPadding = suffixTextPadding;
            return this;
        }

        public Builder setBottomTextSize(int bottomTextSize) {
            arcProgressModel.bottomTextSize = bottomTextSize;
            return this;
        }

        public Builder setBottomText(String bottomText) {
            arcProgressModel.bottomText = bottomText;
            return this;
        }

        public Builder setProgress(int progress) {
            arcProgressModel.progress = progress;
            return this;
        }

        public Builder setMax(int max) {
            arcProgressModel.max = max;
            return this;
        }

        public ArcProgressModel build() {
            return arcProgressModel;
        }

    }
}
